Jump to content

- Functions

- # IsRedirectedFromByNumber()

  Followers 0

  Lua → VBScript

  This function returns true if the call was redirected/transferred by a certain user (extension) or list of extensions, separated by ; (semikolon).

  Please see the Introduction chapter for some usage instructions.

      ------------------------------------------------------------------
      -- IsRedirectedFromByNumber
      --
      -- Returns true if the current call is redirected by any of the numbers
      -- given in the semicolon separated list. It also returns the number that
      -- redirected the call.
      --
      -- Parameter:
      --   sNumbers    semicolon separated list of all numbers
      --
      -- Return:
      --   boolean,
      --      true  - call redirected from given number
      --      false - call not redirected from given number
      --   string
      --      empty if call wasn't redirected by anyone from the list,
      --      otherwise the extension that redirected the call.
      ------------------------------------------------------------------
      function IsRedirectedFromByNumber( sNumbers )
          PBXScript.OutputTrace ("------> IsRedirectedFromByNumber ( '" .. sNumbers .. "' )")

          local bReturn = false
          local sReturn = ""
          local sName   = ""

          local tNumbers = StringSplitToTable(sNumbers, ";")

          for i = 1, #tNumbers do
              PBXScript.OutputTrace ("Checking extension: " .. tNumbers[i])
              sName = GetUserNameFromExtension(tNumbers[i])
              PBXScript.OutputTrace ("Found username: " .. sName)

              if (sName ~= "") then

                  if IsRedirectedFromByName(sName) then
                      PBXScript.OutputTrace ("Call is redirected from this user")
                      bReturn = true
                      sReturn = tNumbers[i]
                  else
                      PBXScript.OutputTrace ("Call is not redirected from this user")
                  end

              end

          end

          PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn))
          PBXScript.OutputTrace ("sReturn = " .. sReturn)
          PBXScript.OutputTrace ("<------ IsRedirectedFromByNumber")

          return bReturn, sNumber
      end

  This function makes use of the function GetUserNameFromExtension() to get the username for a given extension, and also the function IsRedirectedFromByName() to then check if the call is redirected/transferred from that user. It makes also use of the Server Script API function PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. It also uses the GSE build-in helper function StringSplitToTable() to find the caller number in the data from the file.

  Please note: from SwyxWare v13.27 on it is possible to have call routing also for groups and not just users. This function can not be extended to identify the new groups as well, so it can identify users only.

  This function was converted from VBScript into Lua from the initially posted version in this forum topic.

  By Tom Wellige

  - June 5, 2022
  Share
  Share
  Followers 0
  Previous Page IsRedirectedFromByNameEx()
  Next Page IsRedirectionLoopConfigured()

## Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.